<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>运用定时器，让 div 一秒后移动</title>
  <style>
    div {
      width: 50px;
      height: 50px;
      position: absolute;
      background-color: pink;
    }
  </style>
</head>
<body>
  <div></div>
  <script>
      var div = document.querySelector('div')
      var flag = 0;
      // 一秒后执行
      setInterval(function() {
        flag += 10
        div.style.left = flag + "px"
      }, 1000)
  </script>
</body>
</html>